<?php

class DbMapperChain implements IDbMapper
{
    public $table;
	public $primary;
	public $primeAlias;
	public $fields = array();
	public $fieldMaps = array();
	public $relations = array();
	public $properties = array();	
	
	public $isString = false;
	
	protected $mapper = array();
    
    public function addMapper( $mapper )
    {
        $this->mapper[] = $mapper;
    }
    
    public function run( array $map, IDbMapper $chain )
    {
        $this->_clean();
        $chain = empty( $chain )? $this : $chain;
        foreach( $map as $id => $val )
        {
            foreach( $this->mapper as $mapper )
            {
                $mapper->onExtracting( $id, $val, $chain );
            }
        }       
    }
    
    protected function _clean()
    {
        $this->table = '';
        $this->primary = '';
        $this->primeAlias = '';
        $this->fields = array();
        $this->fieldMaps = array();
        $this->relations = array();
        $this->properties = array();
        
    }
}
